package com.example.demo.serviceImpl;

import com.example.demo.entity.ResultMsg;
import com.example.demo.entity.User;
import com.example.demo.dao.UserDao;
import com.example.demo.service.UserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * @Author: zcb
 * @Description:
 * @Date: 2021/9/27
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    @Override
    public User getOne(String name) {
        return userDao.getOne(name);
    }

    @Override
    public ResultMsg insertUser(String name, Byte companyId) {
        User user = new User();
        user.setName(name);
        user.setCompanyId(companyId);
        userDao.insertUser(user);
        return ResultMsg.ok();
    }

    @Override
    public ResultMsg firstUser(String name,Byte companyId) {
        return ResultMsg.successfulData(userDao.firstUser(name, companyId));
    }

    @Override
    public ResultMsg userOrder(String name, Byte companyId) {

        return ResultMsg.successfulData(userDao.userOrder(name, companyId));
    }

    @Override
    public ResultMsg updateUserOrderAmount(Long userId, int amount, Byte companyId) {
        userDao.updateUserOrderAmount(userId, amount, companyId);
        return ResultMsg.ok();
    }


}
